import {QUERY, CLOSE_LIVE_VIDEO, OPEN_LIVE_VIDEO} from '../types/LiveType'

const initState = {
  liveInfoList: [],
  liveVideoVisible: false
}

const liveReducer = (state = initState, dispatch) => {
  switch (dispatch.type) {
    case QUERY: {
      return {
        ...state,
        liveInfoList: dispatch.payload
      }
    }
    case OPEN_LIVE_VIDEO: {
      return Object.assign({}, state, dispatch)
    }
    case CLOSE_LIVE_VIDEO: {
      return Object.assign({}, state, dispatch)
    }
    case "ERROR": {
      return {
        ...state,
        err: dispatch.payload.err
      }
    }
    default:
      return state
  }
}

export default liveReducer